#ifndef _model_h_included_
#define _model_h_included_
#include <d3dx9.h>
#include <d3d9.h>
#include <string>
#include "DXUtil.h"
#include "Mesh.h"
#include <Vector>
#include "Animation.h"
#include "KeyFrame.h"

using namespace std;

#define DEGTORAD(x) (x*D3DX_PI/180.0f)

//This class is responsible for maintaining the state
//of a model
class Model
{
	//The name of the model
	string mName;

	Mesh* mMesh;//The models mesh
	//D3DMATERIAL9 mMaterial; //The models material
	D3DVECTOR mRot; //The rot of the model
	D3DXQUATERNION* mQuat;
	D3DVECTOR mScale; //The Scale of the model
	D3DVECTOR mPos; //The vector of the model

	//Matrices
	D3DXMATRIX* mScaleMatrix;
	D3DXMATRIX* mRotXMatrix;
	D3DXMATRIX* mRotYMatrix;
	D3DXMATRIX* mRotZMatrix;
	D3DXMATRIX* mRotMatrix;
	D3DXMATRIX* mTransMatrix;

	vector<Animation*> mAnimations;
	vector<KeyFrame*> mKeyFrames;

public:
	//Default Constructor sets most everything to zero
	Model();
	Model(string pName, string pTextureLoc);

//Draws the model
	virtual void LoadContent(LPDIRECT3DDEVICE9 d3ddev);
	virtual void Draw(LPDIRECT3DDEVICE9 d3ddev);
	virtual void Update(LPDIRECT3DDEVICE9 d3ddev, double pElapsedTime, double pTotal);
float count;
	string GetName();
	Mesh* GetMesh();
	D3DVECTOR* GetPos();
	D3DVECTOR* GetRot();
	D3DVECTOR* GetScale();
	D3DXQUATERNION* GetQuat();

	void SetName(string pName);
	void SetMesh(Mesh* pMesh);
	void SetQuat(D3DXQUATERNION* pQuat);
	void SetRot(D3DVECTOR* pRot);
	void SetScale(D3DVECTOR* pScale);
    void SetPos(D3DVECTOR* pPos);

	void AddKeyFrame(KeyFrame* pKey);

	//Returns a matrix with all the world transformations done.
	D3DXMATRIX* GetTransMatrix();
	virtual void Release();

	void AddAnimation(Animation* pAnim);
};
#endif